﻿using System;
using System.Windows.Forms;

namespace QuickShot.Shortcut
{
    public sealed class Hotkey : IEquatable<Hotkey>
    {
        public Keys Key { get; set; }
        public Modifiers Modifier { get; set; }

        public static Hotkey None = new Hotkey(Modifiers.None, Keys.None);

        public Hotkey()
        {
            
        }

        public Hotkey(Modifiers modifier, Keys key)
        {
            Modifier = modifier;
            Key = key;
        }

        public override int GetHashCode()
        {
            return (Key == 0 ? 0 : Key.GetHashCode()) ^ (int)Modifier;
        }
        
        public override bool Equals(object obj)
        {
            return Equals(obj as Hotkey);
        }

        public bool Equals(Hotkey other)
        {
            if (other == null) return false;
            return other.Key == Key && other.Modifier == Modifier;
        }

        public static bool operator ==(Hotkey a, Hotkey b)
        {
            return Equals(a, b);
        }

        public static bool operator !=(Hotkey a, Hotkey b)
        {
            return !(a == b);
        }
    }
}
